import React, { Component } from 'react';
import "./App.css"
class App extends Component {
  state ={
    msg:"(*^_^*)"
  }
  getSnapshotBeforeUpdate(){
    // 计算 返回一个数值
    return 500;
  }
  componentDidUpdate(preProps,preState,snapShot){
    // scrollTop
    console.log(snapShot);
    document.getElementById("outerBox").scrollTop = snapShot;
  }
  render() {
    return (
      <div className="outerBox" id="outerBox">
          <div className="innerBox">
            {this.state.msg}
            <button onClick={()=>{
              this.setState({
                msg:"😀"
              })
            }}>更新</button>
          </div>
      </div>
    );
  }
}

export default App;
